import { axiosAccountIns, axiosResourceIns } from "./axios";

const URL = {
  register: "/dp/user/register",
  checkAccount: "/dp/user/checkAccount",
  getPhoneValidCode: "/dp/auth/getPhoneValidCode",
  getAuthResult: "/dp/enterprise/rejected",
  addEnterprise: "/dp/enterprise/add",
  editEnterprise: "/dp/enterprise/edit",
  resetPassword: "/dp/user/resetPasswordByPhone",
  detail: "/dp/enterprise/detail",
  companyCheck: "/dp/enterprise/check",
  /** 产品列表 */
  pList: "/dp/product/list",
  pTree: "/dp/product/tree",
  pAdd: "/dp/product/add",
  pCopy: "/dp/product/copy",
  pDelete: "/dp/product/delete",
};

export async function registerHttp(request: any) {
  request.password = MyModule.smCrypto.sm2(request.password);
  return axiosAccountIns.post(URL.register, request);
}

export async function checkAccount(request: any) {
  return axiosAccountIns.post(URL.checkAccount, request);
}

export async function getPhoneValidCode(request: any) {
  return axiosAccountIns.post(URL.getPhoneValidCode, request);
}

export async function getAuthResult(request: any) {
  return axiosAccountIns.get(URL.getAuthResult, { params: request });
}

export async function addEnterprise(request: any) {
  return axiosAccountIns.post(URL.addEnterprise, request);
}
export async function editEnterprise(request: any) {
  return axiosAccountIns.post(URL.editEnterprise, request);
}
export async function resetPassword(request: any) {
  request.password = MyModule.smCrypto.sm2(request.password);
  return axiosAccountIns.post(URL.resetPassword, request);
}

export async function companyDetail(request: any) {
  return axiosAccountIns.get(URL.detail, { params: request });
}

export async function companyCheck() {
  return axiosAccountIns.get(URL.companyCheck);
}

/** 产品列表 */
export async function productList(request?: any) {
  return axiosResourceIns.get(URL.pList, { params: request });
}

export async function productTree(request: any) {
  return axiosResourceIns.post(URL.pTree, request);
}

export async function productAdd(request: any) {
  return axiosResourceIns.post(URL.pAdd, request);
}

export async function productCopy(request: any) {
  return axiosResourceIns.get(URL.pCopy, { params: request });
}

export async function productDelete(request: any) {
  return axiosResourceIns.get(URL.pDelete, { params: request });
}
